package com.itheima.controller;

import com.itheima.entity.AddressBook;
import com.itheima.service.IAddressBookService;
import com.itheima.util.Result;
import com.itheima.util.UserHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 老师好我是郁同学
 * @date 2022/10/11
 **/
@Slf4j
@RestController
@RequestMapping("/addressBook")
public class AddressBookController {

    @Autowired
    private IAddressBookService addressBookService;

    @PostMapping
    public Result saveAddressBooks(@RequestBody AddressBook addressBook){

        return addressBookService.saveAddressBooks(addressBook);
    }

    @GetMapping("/list")
    public Result addressBooksList(){
        return addressBookService.addressBooksList();
    }

    @GetMapping("/default")
    public Result getAddressBooks(){
        return addressBookService.defaultAddressBooks();
    }
    @PutMapping("/default")
    public Result putAddressBooks(@RequestBody AddressBook addressBook){
        return addressBookService.putAddressBooks(addressBook);
    }
}
